home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / +ORC / Orc pac C / FILEZ.ZIP / IASTUFF.ZIP / IAFILES.ZIP / IASETUP.MST < prev    next >
Encoding:
Text File  |  1997-03-13  |  16.4 KB  |  525 lines

  1. '****************************************************************
  2. '* Instant Access Setup
  3. '* Copyright 1994 Instant Access, Ltd.
  4. '* Version 2.0
  5. '* Note from LJT:  This is spaghetti code because
  6. '*  1.) It's Basic
  7. '*  2.) I started with Microsoft's Example and worked from there.
  8. '*      I was only willing to re-org so much of it.  Believe me
  9. '*      it used to be alot worse than it is now but be warned it's
  10. '*****************************************************************
  11. '$INCLUDE 'setupapi.inc'
  12. '$INCLUDE 'msdetect.inc'
  13.  
  14. 'Dialog ID's
  15.     CONST WELCOME       = 100
  16.     CONST ASKQUIT       = 200
  17.     CONST DESTPATH      = 300
  18.     CONST EXITFAILURE   = 400
  19.     CONST EXITQUIT      = 600
  20.     CONST EXITSUCCESS   = 700
  21.     CONST OPTIONS       = 800
  22.     CONST APPHELP       = 900
  23.     CONST BADWIN        = 1000
  24.     CONST WIN30         = 1100
  25.     CONST APPHELP2      = 1200
  26.     CONST WELCUST       = 1300
  27.     CONST APPHELP1      = 1400
  28.     CONST APPHELP3      = 1500
  29.     CONST NOWIN30       = 1600
  30.     CONST CUSTINST      = 6200
  31.     CONST TOOBIG        = 6300
  32.     CONST BADPATH       = 6400
  33.  
  34. 'Windows constants
  35.     CONST VK_OPTION     = 17
  36.     CONST MASK_VALUE    = 32768
  37.  
  38. 'Bitmap ID
  39.     CONST LOGO          = 1
  40.     CONST TRUE          = 1
  41.     CONST FALSE         = 0
  42.  
  43. 'File Types
  44.     CONST APPFILES      = 1
  45.  
  46. 'General Global Variables
  47.     GLOBAL SRCDIR$      'CD Source Root Directory
  48.     GLOBAL IADIR$       'CD Source Instant Access (ia) Directory
  49.     GLOBAL IAFDIR$      'CD Source Instant Access (iafiles) Directory
  50.     GLOBAL IA$
  51.     GLOBAL DEST$        'Destination Directory
  52.     GLOBAL SRCDRIVE$    'CD-ROM drive letter
  53.     GLOBAL WINDRIVE$    'Windows drive letter
  54.     GLOBAL WINDIR$      'Windows Directory
  55.     GLOBAL WINSYS$      'Windows System Directory
  56.     GLOBAL CUSHION&     'Free disk space after installation
  57.  
  58. 'CustInst list symbol names
  59.     GLOBAL APPNEEDS$    'Program File list costs per drive
  60.     GLOBAL EXTRACOSTS$  'List of extra costs to add per drive
  61.     GLOBAL BIGLIST$     'List of option files cost calc results (boolean)
  62.  
  63. 'Dialog list symbol names
  64.     GLOBAL CHECKSTATES$
  65.     GLOBAL STATUSTEXT$
  66.     GLOBAL DRIVETEXT$
  67.  
  68. 'Global Library References
  69.     GLOBAL CUIDLL$                  'Custom user interface dll
  70.     GLOBAL HELPPROC$                'Help dialog procedure
  71.  
  72. 'Global Debugg
  73.     GLOBAL DEBUG                    'Global Debug flag
  74.  
  75. 'Function & Subroutine Declarations
  76.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  77.     DECLARE FUNCTION EnoughDiskSpace(level%) AS INTEGER
  78.     DECLARE SUB AddOptFilesToCopyList (ftype%)
  79.     DECLARE SUB RecalcOptFiles (ftype%)
  80.     DECLARE SUB RecalcPath
  81.     DECLARE SUB SetDriveStatus
  82.     DECLARE SUB Install
  83.  
  84. 'Direct Access to Windows Routines
  85.     DECLARE FUNCTION GetAsyncKeyState Lib "User" ( vKey%) As INTEGER
  86.  
  87. 'Setup Related Initialization
  88.     DEBUG     = FALSE
  89.     CUIDLL$   = "mscuistf.dll"
  90.     HELPPROC$ = "FHelpDlgProc"
  91.  
  92.     SetBitmap CUIDLL$, LOGO
  93.     SetTitle "Instant Access Setup"
  94.  
  95. 'Get CD ROM Source Directory & Read INF file
  96.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  97.     IF szInf$ = "" THEN
  98.        szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  99.     END IF
  100.     ReadInfFile szInf$
  101.  
  102. 'Initialize General Global Variables
  103.     SRCDIR$     = LCASE$(GetSymbolValue("STF_SRCDIR"))
  104.     IADIR$      = MakePath(SRCDIR$,"ia")
  105.     IAFDIR$     = MakePath(SRCDIR$,"iafiles")
  106.     WINDIR$     = GetWindowsDir()
  107.     WINSYS$     = GetWindowsSysDir()
  108.     SRCDRIVE$   = LCASE$(MID$(SRCDIR$, 1, 1))
  109.     WINDRIVE$   = LCASE$(MID$(WINDIR$, 1, 1))
  110.  
  111. 'Custom Installation list symbols some of which may be used in
  112. 'Basic Installation as well
  113.     CHECKSTATES$= "CheckItemsState"
  114.     STATUSTEXT$ = "StatusItemsText"
  115.     DRIVETEXT$  = "DriveStatusText"
  116.  
  117. 'Disk cost list symbols
  118.     APPNEEDS$   = "AppNeeds"
  119.     EXTRACOSTS$ = "ExtraCosts"
  120.     BIGLIST$    = "BigList"
  121.  
  122. 'Create Items
  123.     FOR i% = 1 TO 3 STEP 1
  124.         AddListItem CHECKSTATES$, ""
  125.     NEXT i%
  126.     FOR i% = 1 TO 3 STEP 1
  127.         AddListItem STATUSTEXT$, ""
  128.     NEXT i%
  129.     FOR i% = 1 TO 7 STEP 1
  130.         AddListItem DRIVETEXT$, ""
  131.     NEXT i%
  132.     FOR i% = 1 TO 3 STEP 1
  133.         AddListItem BIGLIST$, ""
  134.     NEXT i%
  135.     FOR i% = 1 TO 26 STEP 1
  136.         AddListItem EXTRACOSTS$, "0"
  137.     NEXT i%
  138.  
  139. 'Check to see if Option Key is being held down, if so create DEBUG logfile
  140.     IF (GetAsyncKeyState(VK_OPTION) AND MASK_VALUE) <> FALSE THEN
  141.         DEBUG = TRUE
  142.         OpenLogFile WINDRIVE$+":\IASETUP.LOG", 0
  143.         WriteToLogFile "Option key is DOWN"
  144.     END IF
  145.  
  146. 'Throw up the Welcome Dialog.
  147. WELCOME:
  148.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  149.     IF sz$ = "CONTINUE" THEN
  150.        UIPop 1
  151.     ELSE
  152.         GOSUB ASKQUIT
  153.         GOTO WELCOME
  154.     END IF
  155.  
  156. 'Initialize changable globals
  157.     DEST$       = MakePath(WINDIR$,"instanta")
  158.     Installation$ = "Standard"
  159.     ReplaceListItem CHECKSTATES$, 1, "ON"              'Minimum Copy List
  160.  
  161. '***************************************************************************
  162. '* Branch to proper section of code based on installation selection
  163. '***************************************************************************
  164. INSTALL_BRANCH:
  165.     IF DEBUG=TRUE THEN
  166.         WriteToLogFile Installation$ + " Installation"
  167.     END IF
  168.  
  169. '***************************************************************************
  170. '* Process through the Standard Installation Scenario
  171. '***************************************************************************
  172. STANDARD_INSTALLATION:
  173.  
  174. 'First present user with destination path edit dialog
  175.     GOSUB GETPATH
  176.  
  177. 'Now compute what is possible to copy and set it up to be copied
  178.     IF EnoughDiskSpace (APPFILES) = FALSE THEN
  179.        ReplaceListItem CHECKSTATES$, APPFILES, "OFF"
  180.     END IF
  181.  
  182. '***************************************************************************
  183. '* Main Installation Routine
  184. '***************************************************************************
  185. INSTALLATION:
  186.     Install
  187.  
  188. '***************************************************************************
  189. '* Quit Setup
  190. '***************************************************************************
  191. QUIT:
  192.     ON ERROR GOTO ERRQUIT
  193.  
  194.     IF ERR = 0 THEN
  195.        dlg% = EXITSUCCESS
  196.     ELSEIF ERR = STFQUIT THEN
  197.        dlg% = EXITQUIT
  198.     ELSE
  199.        dlg% = EXITFAILURE
  200.     END IF
  201.  
  202. QUIT1:
  203.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  204.     IF sz$ = "REACTIVATE" THEN
  205.         GOTO QUIT1
  206.     END IF
  207.     UIPop 1
  208.     END
  209.  
  210. ERRQUIT:
  211.     i% = DoMsgBox("Setup sources were corrupted, call 0181-200 0100!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  212.     END
  213.  
  214. GETPATH:
  215.     OLDDEST$ = DEST$
  216.     SetSymbolValue "EditTextIn", DEST$
  217.     SetSymbolValue "EditFocus", "END"
  218.  
  219. GETPATH1:
  220.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  221.     DEST$   = LCASE$(GetSymbolValue("EditTextOut"))
  222.  
  223.     IF sz$ = "CONTINUE" THEN
  224.         IF IsDirWritable(DEST$) = 0 THEN
  225.             GOSUB BADPATH
  226.             GOTO GETPATH1
  227.         END IF
  228.         UIPop 1
  229.     ELSEIF sz$ = "REACTIVATE" THEN
  230.         GOTO GETPATH1
  231.     ELSE
  232.         IF Installation$ = "Standard" THEN
  233.            GOSUB ASKQUIT
  234.            GOTO GETPATH
  235.         ELSE
  236.            IF IsDirWritable(DEST$) = 0 THEN
  237.               GOSUB BADPATH
  238.               GOTO GETPATH1
  239.            END IF
  240.            UIPop 1
  241.            DEST$ = OLDDEST$
  242.         END IF
  243.     ELSE
  244.         UIPop 1
  245.     END IF
  246.     RETURN
  247.  
  248. TOOBIG:
  249.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  250.     IF sz$ = "REACTIVATE" THEN
  251.         RecalcPath
  252.         SetDriveStatus
  253.         GOTO TOOBIG
  254.     END IF
  255.     UIPop 1
  256.     RETURN
  257.  
  258. BADPATH:
  259.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  260.     IF sz$ = "REACTIVATE" THEN
  261.         GOTO BADPATH
  262.     END IF
  263.     UIPop 1
  264.     RETURN
  265.  
  266. ASKQUIT:
  267.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  268.     IF sz$ = "EXIT" THEN
  269.         UIPopAll
  270.         ERROR STFQUIT
  271.     ELSEIF sz$ = "REACTIVATE" THEN
  272.         GOTO ASKQUIT
  273.     ELSE
  274.         UIPop 1
  275.     END IF
  276.     RETURN
  277.  
  278. '*************************************************************************
  279. '* Functions & Subroutines
  280. '*************************************************************************
  281. '*************************************************************************
  282. '** Purpose:
  283. '**     Builds the copy list and performs all installation operations.
  284. '** Arguments:
  285. '**     none.
  286. '** Returns:
  287. '**     none.
  288. '*************************************************************************
  289. SUB Install STATIC
  290.  
  291.     CreateDir DEST$,   cmoNone
  292.  
  293. IF DEBUG = TRUE THEN
  294.     WriteToLogFile "Prior to Installation"
  295.     WriteToLogFile "  Source Drive:           "+SRCDRIVE$
  296.     WriteToLogFile "  Source Root Directory:  "+SRCDIR$
  297.     WriteToLogFile "  IA Directory:           "+IADIR$
  298.      WriteToLogFile "  IAFiles Directory:      "+IAFDIR$
  299.     WriteToLogFile "  Destination Directory:  "+DEST$
  300.     WriteToLogFile "  Windows Drive:          "+WINDRIVE$
  301.     WriteToLogFile "  Windows     Directory:  "+WINDIR$
  302.     WriteToLogFile "Status of Check Box State " + STR$(APPFILES)  + " = " +  GetListItem(CHECKSTATES$, APPFILES)
  303. END IF
  304.  
  305.     ClearCopyList
  306.     AddOptFilesToCopyList APPFILES
  307.  
  308.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  309.        ini$ = MakePath(WINDIR$, "IA.INI")
  310. '       CopyFilesInCopyList                     Comment this out for now since we don't need to copy any files.
  311.        CreateProgmanGroup  "Instant Access", "", cmoNone
  312.        ShowProgmanGroup    "Instant Access",  1, cmoNone
  313.        CreateProgmanItem   "Instant Access", "Instant Access Browser", MakePath(SRCDIR$,"iabrowse.exe"), "", cmoOverwrite
  314.        CreateIniKeyValue    ini$,  "Parameters", "CDPath", IAFDIR$, cmoOverwrite
  315.        CreateIniKeyValue    ini$,  "Parameters", "InstantaPath", DEST$, cmoOverwrite
  316.     ELSE
  317.         sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  318.         IF sz$ = "REACTIVATE" THEN
  319.             RecalcPath
  320.             SetDriveStatus
  321.         END IF
  322.         UIPop 1
  323.         ERR = STFQUIT
  324.     END IF
  325.  
  326. END SUB
  327.  
  328. '*************************************************************************
  329. '** Purpose:
  330. '**     Recalculates disk space for the given option files
  331. '** Arguments:
  332. '**     level% - the level of options where each higher level i.e.
  333. '**     OPTFILES2, encompasses all lower levels i.e. APPFILES & OPTFILES1
  334. '** Returns:
  335. '**     none.
  336. '*************************************************************************
  337. FUNCTION EnoughDiskSpace (level%) STATIC AS INTEGER
  338.  
  339. 'Add extra cost to Windows drive for ini/progman, etc.
  340.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  341.        ndrive% = ASC(LCASE$(WINDRIVE$)) - ASC("a") + 1
  342.        ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  343.     END IF
  344.  
  345. 'Compute the cost of the level
  346.     ClearCopyList
  347.     IF level% >= 1 THEN
  348.        AddOptFilesToCopyList APPFILES
  349.     END IF
  350.  
  351.     IF GetCopyListCost(EXTRACOSTS$, "", "") = 0 THEN
  352.        EnoughDiskSpace = TRUE
  353.        IF DEBUG = TRUE THEN
  354.           WriteToLogFile "EnoughDiskSpace at level "+STR$(level%)+" = TRUE"
  355.        END IF
  356.     ELSE
  357.        EnoughDiskSpace = FALSE
  358.        IF DEBUG = TRUE THEN
  359.           WriteToLogFile "EnoughDiskSpace at level "+STR$(level%)+" = FALSE"
  360.        END IF
  361.     END IF
  362.  
  363. END FUNCTION
  364.  
  365. '*************************************************************************
  366. '** Purpose:
  367. '**     Adds the specified option files to the copy list.
  368. '** Arguments:
  369. '**     ftype%  - type of files to add, one of the following:
  370. '**             APPFILES, OPTFILES1, OPTFILES2, PRNTDRVR
  371. '** Returns:
  372. '**     none.
  373. '*************************************************************************
  374. SUB AddOptFilesToCopyList (ftype%) STATIC
  375.  
  376.     SELECT CASE ftype%
  377.       CASE APPFILES
  378.         IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  379.            AddSectionFilesToCopyList "IA Files",      SRCDIR$, DEST$
  380.         END IF
  381.     END SELECT
  382.  
  383. END SUB
  384.  
  385. '*************************************************************************
  386. '** Purpose:
  387. '**     Recalculates disk space for the given option files and sets
  388. '**     the status info symbol "StatusItemsText".
  389. '** Arguments:
  390. '**     ftype% - type of files to add, one of the following:
  391. '**             APPFILES, OPTFILES1, OPTFILES2
  392. '** Returns:
  393. '**     none.
  394. '*************************************************************************
  395. SUB RecalcOptFiles (ftype%) STATIC
  396.     CursorSave% = ShowWaitCursor()
  397.     ClearCopyList
  398.     AddOptFilesToCopyList ftype%
  399.  
  400. 'Add extra cost to Windows drive for ini/progman, etc.
  401.     fExtra% = 0
  402.     IF ftype% = APPFILES THEN
  403.         ListSym$ = APPNEEDS$
  404.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  405.             ndrive% = ASC(LCASE$(WINDRIVE$)) - ASC("a") + 1
  406.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  407.             fExtra% = 1
  408.         END IF
  409.     ELSEIF ftype% = OPTFILES1 THEN
  410.         ListSym$ = OPT1NEEDS$
  411.     ELSEIF ftype% = OPTFILES2 THEN
  412.         ListSym$ = OPT2NEEDS$
  413.     END IF
  414.  
  415.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  416.  
  417.     cost& = 0
  418.     FOR i% = 1 TO 26 STEP 1
  419.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  420.     NEXT i%
  421.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024 ) + " K"
  422.  
  423.     IF StillNeed& > 0 THEN
  424.         ReplaceListItem BIGLIST$, ftype%, "YES"
  425.     ELSE
  426.         ReplaceListItem BIGLIST$, ftype%, ""
  427.     END IF
  428.  
  429.     IF fExtra% THEN
  430.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  431.     END IF
  432.     RestoreCursor CursorSave%
  433.     ListSym$ = ""
  434.  
  435. END SUB
  436.  
  437.  
  438. '*************************************************************************
  439. '**
  440. '** Purpose:
  441. '**     Recalculates disk space and sets option status info according
  442. '**     to the current destination path.
  443. '** Arguments:
  444. '**     none.
  445. '** Returns:
  446. '**     none.
  447. '*************************************************************************
  448. SUB RecalcPath STATIC
  449.  
  450.     CursorSave% = ShowWaitCursor()
  451.  
  452.     RecalcOptFiles APPFILES
  453.     RecalcOptFiles OPTFILES1
  454.     RecalcOptFiles OPTFILES2
  455.  
  456.     RestoreCursor CursorSave%
  457.  
  458. END SUB
  459.  
  460.  
  461. '*************************************************************************
  462. '**
  463. '** Purpose:
  464. '**     Sets drive status info according to latest disk space calcs.
  465. '** Arguments:
  466. '**     none.
  467. '** Returns:
  468. '**     none.
  469. '*************************************************************************
  470. SUB SetDriveStatus STATIC
  471.  
  472.     drive$ = LCASE$(MID$(DEST$, 1, 1))
  473.     ndrive% = ASC(drive$) - ASC("a") + 1
  474.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  475.     free& = GetFreeSpaceForDrive(drive$)
  476.     CUSHION& = free& - cost&
  477.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  478.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  479.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  480.  
  481.     IF drive$ = LCASE$(WINDRIVE$) THEN
  482.         ReplaceListItem DRIVETEXT$, 4, ""
  483.         ReplaceListItem DRIVETEXT$, 5, ""
  484.         ReplaceListItem DRIVETEXT$, 6, ""
  485.     ELSE
  486.         wdrive% = ASC(LCASE$(WINDRIVE$)) - ASC("a") + 1
  487.         cost& = VAL(GetListItem(APPNEEDS$, wdrive%)) + VAL(GetListItem(OPT1NEEDS$, wdrive%)) + VAL(GetListItem(OPT2NEEDS$, wdrive%))
  488.         IF cost& = 0 THEN
  489.             ReplaceListItem DRIVETEXT$, 4, ""
  490.             ReplaceListItem DRIVETEXT$, 5, ""
  491.             ReplaceListItem DRIVETEXT$, 6, ""
  492.         ELSE
  493.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  494.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  495.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  496.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  497.         END IF
  498.     END IF
  499. END SUB
  500.  
  501.  
  502. '*************************************************************************
  503. '**
  504. '** Purpose:
  505. '**     Appends a file name to the end of a directory path,
  506. '**     inserting a backslash character as needed.
  507. '** Arguments:
  508. '**     szDir$  - full directory path (with optional ending "\")
  509. '**     szFile$ - filename to append to directory
  510. '** Returns:
  511. '**     Resulting fully qualified path name.
  512. '*************************************************************************
  513. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  514.     IF szDir$ = "" THEN
  515.         MakePath = szFile$
  516.     ELSEIF szFile$ = "" THEN
  517.         MakePath = szDir$
  518.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  519.         MakePath = szDir$ + szFile$
  520.     ELSE
  521.         MakePath = szDir$ + "\" + szFile$
  522.     END IF
  523. END FUNCTION
  524.  
  525.